#include <cstring>
#include <algorithm>
using namespace std;

class Solution {
public:
    int getLongestPalindrome(string a) {
        int len = a.size();
        bool dp[len+1][len+1];
        memset(dp,false,sizeof(dp));
        int ret = 0;
        for(int i = len-1;i>=0;i--)
        {
            for(int j = 0;j<len;j++)
            {
                if(a[i] == a[j])
                {
                    dp[i][j] = i+1<=j-1?dp[i+1][j-1]:true;
                }
                if(dp[i][j])
                {
                    ret = max(ret,j-i+1);
                }
            }
        }
        return ret;
    }
};